tests/payload-link: Just test a single duplicate object
authorColin Walters <walters@verbum.org>
Thu, 22 Mar 2018 16:47:07 +0000 (12:47 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 22 Mar 2018 19:01:52 +0000 (19:01 +0000)
We were previously assuming that the host content had duplicates,
which...hopefully it doesn't!  We shouldn't rely on that.

Also this test is slow in production and flaky.  Let's just test
a single duplicate object.

Closes: #1509
Approved by: jlebon

tests/installed/itest-payload-link.sh

index 7469f43edcf96d0cdcc6aaab7f9bfdf3302c2da2..f0576d82a8c52199682b589727d6613746c9b3ce 100755 (executable)
@@ -31,9 +31,16 @@ prepare_tmpdir /var/tmp
 trap _tmpdir_cleanup EXIT
 ostree --repo=repo init --mode=archive
 echo -e '[archive]\nzlib-level=1\n' >> repo/config
-host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
-ostree --repo=repo pull-local /ostree/repo ${host_commit}
-ostree --repo=repo refs ${host_commit} --create=${host_nonremoteref}
+
+mkdir content
+cd content
+dd if=/dev/urandom of=bigobject bs=4k count=2560
+cp --reflink=auto bigobject bigobject2
+# Different metadata, same content
+chown bin:bin bigobject2
+cd ..
+ostree --repo=repo commit -b dupobjects --consume --selinux-policy=/ --tree=dir=content
+ostree --repo=repo summary -u
 
 run_tmp_webserver $(pwd)/repo
 
@@ -53,23 +60,24 @@ if ! blkdev=$(losetup --find --show $(pwd)/testblk.img); then
     exit 0
 fi
 
+# This filesystem must support reflinks
 mkfs.xfs -m reflink=1 ${blkdev}
 
 mount ${blkdev} mnt
 cd mnt
 
-# Test that coreutils will do reflink
+# Test that reflink is really there (not just --reflink=auto)
 touch a
 cp --reflink a b
 mkdir repo
 ostree --repo=repo init
 ostree config --repo=repo set core.payload-link-threshold 0
 ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
-ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref}
+ostree --repo=repo pull --disable-static-deltas origin dupobjects
 find repo -type l -name '*.payload-link' >payload-links.txt
-assert_not_streq "$(wc -l < payload-links.txt)" "0"
+assert_streq "$(wc -l < payload-links.txt)" "1"
 
-# Disable logging for inner loop, otherwise it'd be enormous
+# Disable logging for inner loop
 set +x
 cat payload-links.txt | while read i; do
     payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)